package com.biz.primus.ms.payment.api;

import com.biz.primus.base.vo.LongIdVo;
import com.biz.primus.common.vo.SpringPageVO;
import com.biz.primus.model.payment.vo.req.BalanceQueryReqVo;
import com.biz.primus.model.payment.vo.req.PaymentChannelQueryVo;
import com.biz.primus.model.payment.vo.req.PaymentChannelReqVo;
import com.biz.primus.model.payment.vo.resp.BalanceQueryRespVo;
import com.biz.primus.model.payment.vo.resp.PaymentChannelQueryResVo;
import com.biz.primus.model.payment.vo.resp.PaymentChannelResVo;
import com.biz.primus.ms.base.api.BaseApiController;
import com.biz.primus.ms.payment.service.PaymentChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author defei
 * @date 2017/9/22
 */
@RestController
@RequestMapping("soa/paymentChannelService")
@Api(description = "商户支付渠道相关接口文档")
public class PaymentChannelApiController extends BaseApiController {

    private final PaymentChannelService paymentChannelService;

    @Autowired
    public PaymentChannelApiController(PaymentChannelService paymentChannelService) {
        this.paymentChannelService = paymentChannelService;
    }

    @ApiOperation("新增商户支付渠道")
    @PostMapping("create")
    public PaymentChannelResVo create(@RequestBody PaymentChannelReqVo reqVo) {

        return paymentChannelService.create(reqVo);
    }

    @ApiOperation("获取商户支付渠道信息")
    @PostMapping("getPaymentChannelInfo")
    public PaymentChannelResVo findOne(@RequestBody LongIdVo reqVo) {

        return paymentChannelService.getPaymentChannelInfo(reqVo.getId());
    }

    @ApiOperation("获取商户支付渠道信息")
    @PostMapping("getPaymentChannels")
    public List<PaymentChannelQueryResVo> findByMchId(String mchId){

        return paymentChannelService.findAvailablePaymentChannelInfoByMchId(mchId);
    }

    @ApiOperation("根据条件查询分页展示商户渠道信息")
    @PostMapping("findAll")
    public SpringPageVO<PaymentChannelResVo> findAll(@RequestBody PaymentChannelQueryVo queryVo) {

        return paymentChannelService.findAll(queryVo);
    }

    @ApiOperation("更新商户支付渠道信息")
    @PostMapping("update")
    public PaymentChannelResVo update(@RequestBody PaymentChannelReqVo reqVo) {

        return paymentChannelService.update(reqVo);
    }

    @ApiOperation("查询支付渠道用户可用余额")
    @PostMapping("balanceQuery")
    public BalanceQueryRespVo balanceQuery(BalanceQueryReqVo reqVo){

        return paymentChannelService.balanceQuery(reqVo);
    }
}
